package com.pro.common.api.pay.model.db;

import com.pro.common.api.CommonConst;
import com.pro.common.api.model.BaseConfigModel;
import com.pro.common.api.model.auth.IAdminClass;
import com.pro.framework.api.enums.IEnumToDbDbCode;
import com.pro.framework.javatodb.annotation.JTDField;
import com.pro.framework.javatodb.annotation.JTDTable;
import com.pro.framework.javatodb.constant.JTDConst;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 支付商户
 *
 * @author admin
 */
@Data

@EqualsAndHashCode(callSuper = true)
@Schema(description = "支付商户")
@JTDTable(module = CommonConst.Modules.pay,
        sequences = {
                "UNIQUE KEY `code` (`code`)"
        }, entityId = 322)
public class PayMerchant extends BaseConfigModel implements IAdminClass, IEnumToDbDbCode {

    @Schema(description = "商户编号")
    private String code;

    @Schema(description = "商户平台")
    private String platform;

    @Schema(description = "商户名称")
    private String merchantName;

    @Schema(description = "应用Id", example = "少量支付渠道需要")
    private String appId;

    @Schema(description = "补充JSON配置", example = "支付宝或微信等大平台可能需要其他额外参数")
    @JTDField(mainLength = 4000)
    private String extendConfigJson;

    // ===== 代收基础配置（Payment） =====

    @Schema(description = "代收接口地址")
    private String paymentRequestUrl;

    @Schema(description = "代收商户号")
    private String paymentMchId;

    @Schema(description = "代收密钥（秘钥或私钥）")
    private String paymentMchKey;

    @Schema(description = "代收公钥（用于加密/验签）")
    private String paymentPublicKey;

    @Schema(description = "代收私钥（用于签名）")
    @JTDField(mainLength = 2048)
    private String paymentPrivateKey;

    @Schema(description = "代收回调验签用公钥（部分通道回调用此）")
    private String paymentCallbackPublicKey;

    @Schema(description = "代收回调签名用私钥（如果回调时我方需要签名）")
    private String paymentCallbackPrivateKey;

    // ===== 代付基础配置（Payout） =====

    @Schema(description = "代付接口地址")
    private String payoutRequestUrl;

    @Schema(description = "代付商户号")
    private String payoutMchId;

    @Schema(description = "代付密钥（秘钥或私钥）")
    private String payoutMchKey;

    @Schema(description = "代付公钥（用于加密/验签）")
    private String payoutPublicKey;

    @Schema(description = "代付私钥（用于签名）")
    private String payoutPrivateKey;

    @Schema(description = "代付回调验签用公钥")
    private String payoutCallbackPublicKey;

    @Schema(description = "代付回调签名用私钥")
    private String payoutCallbackPrivateKey;

    // ===== 其他配置 =====

    @Schema(description = "是否是线下支付")
    private Boolean offlineFlag;

    @Schema(description = "白名单")
    @JTDField(notNull = JTDConst.EnumFieldNullType.can_null, defaultValue = "NULL")
    private String whitelist;

    @Schema(description = "管理端显示")
    @JTDField(defaultValue = "1")
    private Boolean showAdmin;

}
